package co.yixiang.modules.system.domain;

import co.yixiang.modules.shop.domain.YxUser;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
* @author lijuhunze
* @date 2020-04-28
*/
@Entity
@Data
@Table(name="user_shop")
public class UserShop implements Serializable {

    /** 商户申请ID */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /** 用户ID */
    @OneToOne
    @JoinColumn(name = "uid")
    @ApiModelProperty(value = "用户信息")
    private YxUser user;

    /** 商户所在省 */
    @Column(name = "province",nullable = false)
    @ApiModelProperty(value = "商户所在省")
    private String province;

    /** 商户所在省Code */
    @Column(name = "province_code",nullable = false)
    @ApiModelProperty(value = "商户所在省Code")
    private String provinceCode;

    /** 商户所在市 */
    @Column(name = "city",nullable = false)
    @ApiModelProperty(value = "商户所在市")
    private String city;

    /** 商户所在市Code */
    @Column(name = "city_code",nullable = false)
    @ApiModelProperty(value = "商户所在市Code")
    private String cityCode;

    /** 商户所在区 */
    @Column(name = "district",nullable = false)
    @ApiModelProperty(value = "商户所在区")
    private String district;

    /** 商户所在区Code */
    @Column(name = "district_code",nullable = false)
    @ApiModelProperty(value = "商户所在区Code")
    private String districtCode;

    /** 商户详细地址 */
    @Column(name = "address",nullable = false)
    @ApiModelProperty(value = "商户详细地址")
    private String address;

    /** 商户名称 */
    @Column(name = "merchant_name",nullable = false)
    @ApiModelProperty(value = "商户名称")
    private String merchantName;

    @Column(name = "link_user",nullable = false)
    @ApiModelProperty(value = "")
    private String linkUser;

    /** 商户电话 */
    @Column(name = "link_tel",nullable = false)
    private String linkTel;

    /** 商户证书 */
    @Column(name = "charter",nullable = false)
    @ApiModelProperty(value = "商户证书")
    private String charter;

    /** 添加时间 */
    @Column(name = "add_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime addTime;

    /** 审核时间 */
    @Column(name = "apply_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime applyTime;

    /** 通过时间 */
    @Column(name = "success_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime successTime;

    /** 未通过原因 */
    @Column(name = "fail_message")
    @ApiModelProperty(value = "未通过原因")
    private String failMessage;

    /** 未通过时间 */
    @Column(name = "fail_time")
    @ApiModelProperty(value = "未通过时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime failTime;

    /** -1 审核未通过 0未审核 1审核通过 */
    @Column(name = "status",nullable = false)
    @ApiModelProperty(value = "审核状态,-1 审核未通过 0未审核 1审核通过")
    private Integer status;

    /** 身份证正面 */
    @Column(name = "id_font",nullable = false)
    @ApiModelProperty(value = "身份证正面")
    private String idFont;

    /** 身份证反面 */
    @Column(name = "id_reverse",nullable = false)
    @ApiModelProperty(value = "身份证反面")
    private String idReverse;

    /** 商户图片 */
    @Column(name = "image",nullable = false)
    @ApiModelProperty(value = "商户图片")
    private String image;

    /** 是否推荐,0否，1是 */
    @Column(name = "is_hot",nullable = false)

    @ApiModelProperty(value = "是否推荐,0否，1是 ")
    private Integer isHot;

    /** 0 = 开启 1= 关闭 */
    @Column(name = "is_lock",nullable = false)
    @ApiModelProperty(value = "0 = 开启 1= 关闭 ")
    private Integer isLock;

    /** 是否删除 */
    @Column(name = "is_del",nullable = false)
    @ApiModelProperty(value = "是否删除,0 开启 ,1 关闭 ")
    private Integer isDel;

    /**
     * 商户头像
     */
    @Column(name = "head_image",nullable = false)
    @ApiModelProperty(value = "商户头像")
    private String headImage;

    /**
     * 背景图片
     */
    @Column(name = "background_img",nullable = false)
    @ApiModelProperty(value = "背景图片")
    private String backgroundImg;


    public void copy(UserShop source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}